<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/tags/struts-bean" prefix="bean"%>
<%@ taglib uri="/tags/struts-html" prefix="html"%>
<%@ taglib uri="/tags/struts-logic" prefix="logic"%>
<html:html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>码表维护管理</title>
	<META http-equiv=Pragma content=no-cache>
	<META http-equiv=Cache-Control content=no-cache>
	<META http-equiv=Expires content=0>
	<link rel="stylesheet"
		href="<%=request.getContextPath()%>/resource/css/style.css"
		type="text/css">
	<script language="javascript" type="text/javascript"
		src="<%=request.getContextPath()%>/resource/js/util.js"></script>
	<script language="javascript" type="text/javascript"
		src="<%=request.getContextPath()%>/style/scripts/util.js"></script>
	<script language="javascript" type="text/javascript"
		src="<%=request.getContextPath()%>/resource/js/AdyhUtil.js"></script>
	<script language="javascript" type="text/javascript"
		src="<%=request.getContextPath()%>/resource/js/Validator.js"></script>
	<script language="javascript" type="text/javascript"
		src="<%=request.getContextPath()%>/resource/calendar/DCDA_C03.js"></script>
	<script type="text/javascript"
		src="<%=request.getContextPath()%>/style/ext/adapter/ext/ext-base.js"></script>
	<script type="text/javascript"
		src="<%=request.getContextPath()%>/style/ext/ext-all.js"></script>
	<script>

/**保存*/
function ShowAlert()
{ResetMe();
	var code = document.getElementById("code").value;
	var name = document.getElementById("name").value;
	var objPrompt = document.getElementById("divPrompt");
    objPrompt.style.display = "block";
    objPrompt.innerHTML = "";
	if(code.length==0||name.length==0){
		if(code.length==0){
			objPrompt.innerHTML += "<li><bean:message key="F010101.customers_name"/><bean:message key="F01.errerNull"/>！";
			document.getElementById("code").className = "MyControlError";
		}
		if(name.length==0){
			objPrompt.innerHTML += "<li><bean:message key="F010101.contact_name"/><bean:message key="F01.errerNull"/>！";
			document.getElementById("name").className = "MyControlError";
		}
	}else{
	//	SampleCode();
	//	SampleName();
	//	Sample();
		var bs1 = document.getElementById("bs1").value;
		var bs2 = document.getElementById("bs2").value;
		var bs3 = document.getElementById("bs3").value;
		if(bs1>0||bs2>0||bs3>0){
			if(bs1>0){
				objPrompt.innerHTML += "<li>代码重复！";
				document.getElementById("name").className = "MyControlError";
			}
			if(bs2>0){
				objPrompt.innerHTML += "<li>名稱重复！";
				document.getElementById("name").className = "MyControlError";
			}
			if(bs3>0){
				objPrompt.innerHTML += "<li>名稱對應代码重复！";
				document.getElementById("name").className = "MyControlError";
			}
		}else{
			var operationType = document.getElementById("operationType").value;
			operation(operationType);
		}
	}
}
/**重置*/
function ResetMe()
{
    document.getElementById("code").className = "MyText";
	document.getElementById("name").className = "MyArea";
	
	var objPrompt = document.getElementById("divPrompt");
    objPrompt.style.display = "none";
	objPrompt.innerHTML = "";
}
function ShowFormTitle(strTitle)
{			var title = document.getElementById("tablename").value;
	document.write("<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" style=\"height:26px; background-position: left bottom; background-image: url(../../resource/image/FormTitle_A_4.gif); background-repeat: repeat-x;\">");
	document.write("  <tr >");
	document.write("	<td style=\"width:5px; background-position: left bottom; background-image: url(../../resource/image/FormTitle_A_1.gif); background-repeat: no-repeat;\">&nbsp;&nbsp;&nbsp;</td>");
	document.write("	<td class=\"FormTitle\" style=\"width:100%; padding-left:5px; padding-top:3px; background-position: left bottom; background-image: url(../../resource/image/FormTitle_A_2.gif); background-repeat: no-repeat;\">");
	document.write("		<span id=\"spanFormTitle\" class=\"SpanTitle\">"+ title +"</span>");
	document.write("	</td>");
	document.write("	<td style=\"width:5px; background-position: right bottom; background-image: url(../../resource/image/FormTitle_A_3.gif); background-repeat: no-repeat;\">&nbsp;&nbsp;&nbsp;</td>");
    document.write("  </tr>");
	document.write("</table>");
}
function getMessage(){
	var operationType = document.getElementById("operationType").value;
	if("update"==operationType){
		document.forms[0].code.disabled=true;
	}
}

function SampleCode(){
  	var code = document.forms[0].code.value;
  		Ext.Ajax.request({
			url : 'F010106.do' , 
			params : {operationType:'check',type:'dm',code:code},
			method: 'POST',
			success: function ( result, request) {
				var obj= Ext.decode(result.responseText) ;
				var falg = obj.data.value1;
				document.forms[0].bs1.value=falg;
			},
			failure: function ( result, request) { 
				window.parent.alert("无法连接服务器和数据库，请和系统管理员联系！");
			} 
	    });
}

function SampleName(){
  	var name = document.forms[0].name.value;
  		Ext.Ajax.request({
			url : 'F010106.do' , 
			params : {operationType:'check',type:'mc',name:name},
			method: 'POST',
			success: function ( result, request) {
				var obj= Ext.decode(result.responseText) ;
				var falg = obj.data.value1;
				document.forms[0].bs2.value=falg;
			},
			failure: function ( result, request) { 
				window.parent.alert("无法连接服务器和数据库，请和系统管理员联系！");
			} 
	    });
}

function Sample(){
  	var code = document.forms[0].code.value;
  	var name = document.forms[0].name.value;
  		Ext.Ajax.request({
			url : 'F010106.do' , 
			params : {operationType:'check',type:'sample',code:code,name:name},
			method: 'POST',
			success: function ( result, request) {
				var obj= Ext.decode(result.responseText) ;
				var falg = obj.data.value1;
				document.forms[0].bs3.value=falg;
			},
			failure: function ( result, request) { 
				window.parent.alert("无法连接服务器和数据库，请和系统管理员联系！");
			} 
	    });
}
</script>
</head>

<body onLoad="getMessage();">
	<html:form method="post" action="/pages/F01/F010106.do">
		<html:hidden property="operationType" />
		<html:hidden property="errorFlag" />
		<html:hidden property="tablename" />
		<html:hidden property="bs1" />
		<html:hidden property="bs2" />
		<html:hidden property="bs3" />
		<!--Begin：表单标题-->
		<div class="DivBlock">
			<script language="javascript" type="text/javascript">
		ShowFormTitle("");
	</script>
		</div>
		<!--End：表单标题-->

		<!--Begin：表单主体区块-->
		<div class="DivBlock">
			<div class="DivWrap" style="display:block">
				<TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0">
					<TR>

						<TD ALIGN="right" NOWRAP>
							<bean:message key="F010106.code"/>
						</TD>
						<TD ALIGN="left" NOWRAP>
							<html:text property="code" styleClass="MyText"
								onchange="javascript:SampleCode()" />
							<span class="Need">*</span>
						</TD>
						<TD ALIGN="right" NOWRAP>
							<bean:message key="F010106.name"/>
						</TD>
						<TD ALIGN="left" NOWRAP>
							<html:text property="name" styleClass="MyText"
								onchange="javascript:SampleName()" />
							<span class="Need">*</span>
						</TD>
					</TR>
				</TABLE>
			</div>
		</div>
		<!--End：表单主体区块-->

		<!--Begin：表单按钮及提示区-->
		<div class="DivBlock">
			<div class="DivButton">
				<input type="button" name="Submit1" class="MyButton"
					onClick="ShowAlert()" value="<bean:message key="common.save"/>">
				<input type="button" name="Submit2" class="MyButton"
					value="<bean:message key="common.back"/>"
					onClick="javascript:operation('back');">
			</div>
			<div class="DivPrompt" id="divPrompt" style="display:none">
			</div>
		</div>
		<!--End：表单按钮及提示区-->
	</html:form>
</body>
</html:html>
<script language="javascript" type="text/javascript">
InitForm();
</script>
